export default {
    namespaced: true,
    state: {
        // 是否显示提示组件
        isShowToast: false,
        // 提示内容
        toastMsg: "",
        // 提示类型 success成功 error出错 warning警告
        toastType: ""
    },
    mutations: {
        changeIsShowToast(state, payload) {
            state.isShowToast = payload.isShow
            if (payload.isShow) {
                state.toastMsg = payload.msg
                state.toastType = payload.type
            }
        }
    },
    actions: {
        asyncShowToast(context, payload) {
            // 显示提示框(调用mutations方法)
            context.commit("changeIsShowToast", payload)
            // 自动隐藏
            setTimeout(() => {
                context.commit("changeIsShowToast", {
                    isShow: false
                })
            }, 2000)
        }
    }
}